package kingwing.dc.core.sevice.quartz.dao;

import java.io.Serializable;
import java.util.Date;

import kingwing.dc.core.model.BaseEntity;

import org.hibernate.Session;
import org.springframework.stereotype.Component;

import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
import com.bstek.bdf2.core.orm.hibernate.ISessionCallback;

@Component(JObHibernateDao.BEAN_ID)
public class JObHibernateDao extends HibernateDao {

	public static final String BEAN_ID = "KingWing.jObHibernateDao";
	
	
	/**
	 * 保存一个实体对象
	 * 
	 * @param entity
	 * @return
	 */
	public Serializable save(final BaseEntity entity) {
		return this.doInHibernateSession(new ISessionCallback<Serializable>() {

			@Override
			public Serializable doInSession(Session session) {
				entity.setCreateDate(new Date());
				return session.save(entity);
			}

		});
	}
	
	
}
